Conversation
...in/java/io/temporal/spring/boot/autoconfigure/properties/WorkersAutoDiscoveryProperties.java
Outdated
Show resolved
Hide resolved
...in/java/io/temporal/spring/boot/autoconfigure/properties/WorkersAutoDiscoveryProperties.java
Outdated
Show resolved
Hide resolved
|
For manual config the properties are like Given that I might change some of the names here like |
|
How will a user know |
e1e5413 to
e790f32
Compare
Turns out Spring Boot has its own annotation for that purpose. I added it. |
| * <p>Classpath-scanning via {@link #workflowPackages} (for non-bean workflow classes) still | ||
| * requires explicit package configuration regardless of this flag. | ||
| */ | ||
| private final @Nullable Boolean enable; |
There was a problem hiding this comment.
nit: Should probably choose enabled instead of enable to follow more closely to general Spring ecosystem convention. This is just my Spring exposure, so if you've seen it more commonly expressed enable that'd be interesting to learn!
There was a problem hiding this comment.
Thanks a lot for your input! After some search, enabled indeed seems more idiomatic to the Spring Boot community.
Fixes #2780.
Problem
@ActivityImpl- and@NexusServiceImpl-annotated Spring beans were silently not registered with Temporal workers unlessspring.temporal.workers-auto-discovery.packageswas configured — even though that setting is only supposed to control workflow classpath scanning. The entire auto-discovery block (activities, nexus services, and workflows) was gated onpackages != nullinWorkersTemplate.createWorkers().Solution
Separate the concerns with explicit opt-in flags under
spring.temporal.workers-auto-discovery:register-activity-beansbooleanfalse@ActivityImpl-annotated Spring beans with matching workersregister-nexus-service-beansbooleanfalse@NexusServiceImpl-annotated Spring beans with matching workersworkflow-packageslist@WorkflowImplclasses (replacespackages)enablebooleanfalse@WorkflowImpl,@ActivityImpl, and@NexusServiceImplSpring-managed beans without package scanningThe
enable: trueflag covers the common case where all implementations are Spring-managed beans. For more control,register-activitiesandregister-nexus-operationscan be set independently, andworkflow-packageshandles classpath scanning for workflow classes that are not Spring beans.Backward compatibility
The existing
packagesproperty is deprecated but fully preserved:register-activities: true,register-nexus-operations: true, and its entries are treated asworkflow-packages.packageswith any of the new properties throwsIllegalStateExceptionat startup with a clear migration message.Changes
WorkersAutoDiscoveryProperties— new fields, deprecation logic, validation, computed accessors (isRegisterActivities(),isRegisterNexusOperations(),isRegisterWorkflowBeans(),getEffectiveWorkflowPackages())WorkersTemplate— auto-discovery block rewritten to use the new property accessors independently; addedautoDiscoverWorkflowBeans()for bean-based workflow discoveryWorkersPresentCondition— bindsWorkersAutoDiscoveryPropertiesas a whole (was binding onlypackages), so the condition fires for anyworkers-auto-discoveryconfigurationapplication.yml(tests) — existing profiles migrated frompackages:toworkflow-packages:+ explicit flags; legacypackagesbehavior tested via the newauto-discovery-by-task-queue-legacyprofileAutoDiscoveryActivitiesOnlyTest,AutoDiscoveryEnableTest,AutoDiscoveryByTaskQueueLegacyTest,AutoDiscoveryMixedPropertiesRejectedTest